package Survey;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.util.Vector;

public class SurveyCreator {
	
	Vector<SurveyParameters> surveys;
	
	public SurveyCreator(){
		
		ObjectInputStream in = null;
		try {
			in = new ObjectInputStream(new FileInputStream("surveys.dat"));
		} catch (FileNotFoundException e) {}
		  catch (IOException e) {}
		
		if(in != null){
			try {
				surveys = (Vector<SurveyParameters>) in.readObject();
			} catch (IOException e) {e.printStackTrace();} 
			  catch (ClassNotFoundException e) {e.printStackTrace();}
		}else{
			surveys = new Vector<SurveyParameters>();
		}
		SurveyCreatorGui scg = new SurveyCreatorGui(surveys, this);
		scg.updateSize();
	}

	public void saveData(){
				
		ObjectOutputStream out = null;
		try{
			out = new ObjectOutputStream(new FileOutputStream("surveys.dat"));
			out.writeObject(surveys);
			out.flush();
			out.close();
		}
		catch(FileNotFoundException ex){ex.printStackTrace();}
		catch(IOException e) {e.printStackTrace();}
		
	}
	
	public static void main(String[] args){
		new SurveyCreator();
	}
	
}
